package cn.xinfei.xdecision.model;

import cn.xinfei.xdecision.common.model.datax.enums.VariableStrategyType;
import cn.xinfei.xdecision.data.model.IVariableRequest;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;

@Data
public class BaseVarRequest implements IVariableRequest {

    /**
     * 风控id
     */
    protected String requestId;

    /**
     * 请求方分组
     */
    private String requestGroup = "DEFAULT";
    /**
     * 需要采集&计算的变量 eg: 接口变量，sql变量，衍生变量
     */
    protected Set<String> varCodes;
    /**
     * 输入变量&常变量 不需要采集&计算
     */
    protected JSONObject inputParams = new JSONObject();

    /**
     * 变量策略类型
     */
    protected List<VariableStrategyType> variableStrategyTypes = new ArrayList<>();

    @Override
    public List<VariableStrategyType> requestStrategys() {
        return variableStrategyTypes;
    }

    @Override
    public String requestId() {
        return requestId;
    }

    @Override
    public Set<String> varCodes() {
        return varCodes;
    }

    @Override
    public JSONObject inputParams() {
        return inputParams;
    }

    public String getGroup() {
        return Objects.isNull(this.requestGroup) ? "DEFAULT" : this.requestGroup;
    }
}
